<?php
//Importacion y creacion de instancia de la clase queries_showImage.php
require('./roots.php');
require($root_path.'db/interconsulta/include/queries_showImagePregResp.php');
require($root_path.'include/inc_environment_global.php');
$query_showImagePregResp = new Queries_showImagePregResp();
GLOBAL $db;
include('./connection.php');
	$id = $_GET['id'];
	$idPreg = $_GET['idPreg'];
	$name = $_GET['name'];
        $resp = $_GET['resp'];

	//$sql = "SELECT name,content FROM care_interconsulta_adjuntos$resp WHERE id_interconsulta=".$id." AND id_preg = " . $idPreg . " AND name='".$name."'";
	$sql = $query_showImagePregResp->select_care_interconsulta_adjuntos($resp, $id, $idPreg, $name);
	if (!strcmp("mysql", $dbtype))
        {
            /*mysql_connect($dbhostname, $dbusername, $dbpassword);
            mysql_select_db($dbname);
            $res = mysql_query($sql);
            $row = mysql_fetch_array($res, MYSQL_ASSOC);
            ;*/
        	$row=$db->GuiSelect(array("name","content"),array('id_interconsulta'=>$id,'name'=>$name,'id_preg'=>$idPreg),"care_interconsulta_adjuntos".$resp."");
        	//var_dump($row[0]['name']);
        	
        }
	$nombreC= explode('.',$row[0]['name']);
 	$type = $nombreC[sizeOf($nombreC)-1];
 	$bytes = $row[0]['content'];
 	//var_dump($type);

	header("Content-type: ".$type);
	print $bytes;
?>
